package com.zhuoya.healthcard.update;

import android.content.Context;
import android.support.annotation.NonNull;


import androidx.work.Worker;
import androidx.work.WorkerParameters;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.zhuoya.healthcard.net.ApiRequestCallBack;
import com.zhuoya.healthcard.net.CommonApiClient;


/**
 * @Author: guolinguang
 * @Date: 2020/9/14 16:43
 * @Description: 后台每个15分钟检查更新
 **/
public class UpdateWorker extends Worker {
    public UpdateWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    @NonNull
    @Override
    public Result doWork() {
        ToastUtils.showShort("开始检查升级");
        LogUtils.d("checkUpdate");
        CommonApiClient.getInstance().checkUpdate(new ApiRequestCallBack<UpdateEntity>(){
            @Override
            public void onSuccess(UpdateEntity data) {
                AppUpdate.getInstance().startUpdate(data);
            }
        });

        return null;
    }
}
